#define _GNU_SOURCE
#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>
#include<unistd.h>

//first thread
void * first_thread(void *arg){
    printf("first thread......id:%d\n",gettid());

    sleep(5);
    printf("first thread stop");
}

int main(int argc, char const *argv[])
{
    printf("处于主进程的 主线程的执行开始  id:%d\n",gettid());

    //创建两个分线程
    pthread_t pt; //线程句柄
    pthread_create(&pt,NULL,first_thread,NULL);

    sleep(1);

    pthread_cancel (pt);
    //等待两个分线程执行结束
    pthread_join(pt,NULL);

    printf("主线程的执行结束\n");
    return 0;
}

